<template>
	<view class="nt-cdn-image" :style="style">
		<image @tap="$emit('imageTap')" :mode="mode" :src="imageUrl"></image>
	</view>
</template>

<script>
	import {
		appConfig
	} from "@/config"
	export default {
		props: {
			src: {
				type: String,
				default: ""
			},
			mode: {
				type: String,
				default: "aspectFill"
			},
			width: {
				type: String,
				default: "100%"
			},
			height: {
				type: String,
				default: "100%"
			}
		},
		computed: {
			style() {
				return `width: ${this.width};height: ${this.height}`
			},
			imageUrl() {
				return (appConfig.imgCDN + this.src).replace(/\\/g, "/")
			}
		},
	}
</script>

<style scoped lang="scss">
	.nt-cdn-image,
	image {
		width: 100%;
	}

	image {
		height: 100%;
	}
</style>